package com.qf.Utils;/*
 *
 */

import java.math.BigInteger;
import java.security.MessageDigest;

public class Md5Utils {
    public static String md5(String str) {
        try {
            //创建消息摘要
            MessageDigest messageDigest = MessageDigest.getInstance("MD5");
            //更新数据
            messageDigest.update(str.getBytes());
            //获取加密数据
            byte[] digest = messageDigest.digest();
            //转换为16进制
            return new BigInteger(1,digest).toString();
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }
    }
}
